package net.oschina.app.factory;


import android.os.Bundle;
import android.support.v4.app.Fragment;

import net.oschina.app.fragment.me.favorite.BlogFragment;
import net.oschina.app.fragment.me.favorite.CodeFragment;
import net.oschina.app.fragment.me.favorite.InformationFragment;
import net.oschina.app.fragment.me.favorite.SoftwareFragment;
import net.oschina.app.fragment.me.favorite.TopicFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wei03 on 2017/1/13.
 */

public class FavoriteFragmentFactory extends BaseFactory{
    public  Fragment getFragment(int position) {
        Map<Integer, Fragment> fragments = new HashMap<>();
        Fragment fragment = fragments.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new SoftwareFragment();
                    Bundle soft = new Bundle();
                    soft.putString("type","1");
                    fragment.setArguments(soft);
                    break;
                case 1:
                    fragment = new TopicFragment();
                    Bundle topic = new Bundle();
                    topic.putString("type","2");
                    fragment.setArguments(topic);
                    break;
                case 2:
                    fragment = new CodeFragment();
                    Bundle code = new Bundle();
                    code.putString("type","5");
                    fragment.setArguments(code);
                    break;
                case 3:
                    fragment = new BlogFragment();
                    Bundle blog = new Bundle();
                    blog.putString("type","3");
                    fragment.setArguments(blog);
                    break;
                case 4:
                    fragment = new InformationFragment();
                    Bundle information = new Bundle();
                    information.putString("type","4");
                    fragment.setArguments(information);
                    break;
                default:
                    fragment = new SoftwareFragment();
            }
            fragments.put(position, fragment);
        }
        return fragment;
    }
}
